<template lang="pug">
.page
  .area-manage
    .search-form.mb-10.pl-10.pr-10
      Row(type="flex" justify="start")
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 社保编号：
          Input(v-model="securityNO" placeholder="请输入" clearable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 单位名称：
          Input(v-model="companyName" placeholder="请输入" clearable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w90 参保地区：
          Cascader(v-model="areaName" placeholder="请选择参保地区" change-on-select :data="ProvinceArr" :load-data="loadDataCity" style="width:100%;" filterable)
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 服务形式：
          Select(v-model="serviceForm" clearable)
            Option(v-for="item in serviceFormArr" :value="item.value" :key="item.value") {{item.text}}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 社保专员：
          Select(v-model="commissionerUserId" label-in-value clearable filterable)
            Option(v-for="item in commissionerUserIdArr" :value="item.key" :key="item.key") {{item.value}}
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 是否收款：
          RadioGroup.beautiful-radio-group(type="button" v-model="isReceivables")
            Radio(label="") 全部
            Radio(label="true") 是
            Radio(label="false") 否
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 是否开票：
          RadioGroup.beautiful-radio-group(type="button" v-model="isInvoice")
            Radio(label="") 全部
            Radio(label="true") 是
            Radio(label="false") 否
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          span.label-txt.w80 状态：
          RadioGroup.beautiful-radio-group(type="button" v-model="enabled")
            Radio(label="") 全部
            Radio(label="true") 启用
            Radio(label="false") 禁用
        Col.pr-20.mb-15(:md="{ span: 12 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          Button.ml-10(v-if="hasFind" type="info" @click="searchBtn") 查询
    .odd-manage.pl-20.pr-20.bg-white
      Table.hasTitle-table.beautiful-table(width="100%" :loading="loading" stripe :columns="thead" :data="codeListData" @on-selection-change="tableSelectChange")
        .clearfix.font-14(slot="header")
          .table-title-lefttxt.pull-left
            span
              | 社保编号:
              span.text-info.pl-5.pr-5.font-weight {{securityNoCount}}
              | 条
            Divider(type="vertical")
            span
              | 参保地区:
              span.text-info.pl-5.pr-5.font-weight {{areaCount}}
              | 个
          .pull-right.table-title-btns
            Button.mr-15(v-if="hasCreate" size="small" type="info" @click="addFn") 新增
            Button.mr-15(v-if="hasImport" size="small" type="info" @click="importBtn") 批量导入
            Button.mr-15(v-if="hasExport" size="small" type="info" @click="exportBtn") 导出
        template(slot-scope="{ row, index }" slot="operation")
          Button.mr-5(v-if="hasView" type="text" size="small" @click="checkInfoFn(row.id)") 查看
          Button(v-if="hasEdit" type="text" size="small" @click="getReviseAfInfo(row.id)") 修改
          Button(v-if="hasDisEnabled && row.enabled" type="text" size="small" @click="getEnabled(row.id,false)") 禁用
          Button(v-if="hasEnabled && !row.enabled" type="text" size="small" @click="getEnabled(row.id,true)") 启用
          
        .clearfix.pl-20.pr-20(slot="footer")
          Page(:total="codeTotal" :current="PageIndex" :page-size="PageSize" prev-text="上一页" next-text="下一页" @on-change="pageChangeFn" show-total @on-page-size-change="onpageSizeChange" show-sizer :page-size-opts="[10, 20, 30, 50, 100]")
    include ./modal/add.pug
    include ./modal/check.pug
    BatchImportModal(ref="BatchImportModal" :securityType="securityType" @query="searchBtn" @handleMaxSizeTen="handleMaxSizeTen")

</template>

<script>
import systemApi from '@/api/system.js'
import dataApi from '@/api/data.js'
import codeManageApi from '@/api/codeManage.js'

import BatchImportModal from './modal/BatchImportModal.vue'

export default {
  name: 'ssCodeManage',
  components: {
    BatchImportModal
  },
  data () {
    return {
      isReceivables: '', // 是否收款
      isInvoice: '', // 是否开票
      serviceFormArr: [],
      serviceForm: '', // 服务形式
      add_isReceivables: true, // 新增时是否收款
      add_isInvoice: true, // 新增时是否开票
      add_serviceForm: '', // 新增时服务形式
      add_serviceFormName: '', // 新增时服务形式
      // add_lateFeesCanCollect: false, // 是否收取滞纳金
      // add_lateFeesStartMonth: 0, // 滞纳金收取开始月
      // add_lateFeesPercent: 0, // 滞纳金收取比例
      commissionerUserId: '',
      add_commissionerUserId: '',
      add_commissionerUserName: '',
      commissionerUserIdArr: [],
      enabled:'',
      add_enabled: true,

      areaCount: 0,
      securityNoCount: 0,
      // 弹窗加载状态
      spinShow: false,
      // 参保类型（1社会保险、2公积金）
      securityType: 1,
      // areaArr: areaData,
      // 省份数组
      ProvinceArr: [],
      // 查询-参保地区
      areaName: [],
      // 社保编号
      securityNO: '',
      // 单位名称
      companyName: '',
      // 方案列表
      codeListData: [],
      // 方案总数
      codeTotal: 0,
      PageIndex: 1,
      PageSize: 10,
      loading: false,
      // 选择的id集合
      selectedId: '',
      // 新增弹窗
      addModalShow: false,
      // 查看修改弹窗
      checkModalShow: false,
      // 查看和修改弹窗的title
      checkModalTitle: '编号查看',
      // 是否处于查看状态
      isCheckModel: false,
      // 编号详情，点击查看和修改时获取
      codeDetailInfo: {},
      // 新增时获取的提交信息集合
      addDetailInfo: {},
      // 查看详情id
      detail_id: '',
      // 查看-参保地区
      dt_area_name: '',
      dt_area_name_id: '',
      // 查看-参保方案
      dt_planName: '',
      // 新增-参保地区
      add_area_name: [],
      // 新增--社保编号
      add_securityNO: '',
      // 新增--单位名称
      add_companyName: '',
      // 参保方案下拉选项
      planOptions: [],
      // 新增时参保方案下拉选项
      add_planOptions: [],
      // 新增时参保方案id
      add_planGUID: '',
      add_dis: true,
      // 全部--默认基数
      baseAmountValue: '',
      // 全部--最低基数
      minAmountValue: '',
      // 全部--最高基数
      maxAmountValue: '',
      // 全部--补缴
      allIsPayBack: false,
      // 全部--收费精度
      allPrecision: '',
      // 收费精度下拉
      precisionSelect: [],
      // 大病医疗收费方式
      securityPaymentType: null,
      // 计算方式下拉
      countType: null,
      // 生效时间下拉
      effectiveTime: null,
      // 表头
      thead: [
        {
          type: 'selection',
          align: 'center',
          fixed: 'left',
          width: 60
        },
        {
          title: '社保编号',
          align: 'center',
          tooltip: true,
          minWidth: 100,
          key: 'securityNO'
        },
        {
          title: '单位名称',
          align: 'center',
          tooltip: true,
          minWidth: 150,
          key: 'companyName'
        },
        {
          title: '参保地区',
          align: 'center',
          minWidth: 90,
          key: 'areaName'
        },
        {
          title: '社保方案',
          align: 'center',
          tooltip: true,
          minWidth: 90,
          key: 'planName'
        },
        {
          title: '是否收款',
          align: 'center',
          minWidth: 90,
          render: (h, params) => {
            return h('span', params.row.isReceivables?'是':'否')
          }
        },
        {
          title: '是否开票',
          align: 'center',
          minWidth: 90,
          render: (h, params) => {
            return h('span', params.row.isInvoice?'是':'否')
          }
        },
        {
          title: '服务形式',
          align: 'center',
          tooltip: true,
          minWidth: 90,
          key: 'serviceFormName'
        },
        {
          title: '社保专员',
          align: 'center',
          minWidth: 90,
          key: 'commissionerUserName'
        },
        {
          title: '状态',
          align: 'center',
          minWidth: 190,
          key: 'enabled',
          render: (h, params) => {
            let row = params.row
            return h('span', row.enabled?'启用':'禁用')
          }
        },
        {
          title: '添加时间',
          align: 'center',
          minWidth: 180,
          key: 'createdOn',
          render: (h, params) => {
            let row = params.row
            let times = row.createdOn.slice(0, 19).replace(/T/g, ' ')
            return h('span', times)
          }
        },
        {
          title: '添加人',
          align: 'center',
          minWidth: 100,
          key: 'createdName'
        },
        {
          title: '操作',
          key: 'action',
          align: 'center',
          slot: 'operation',
          minWidth: 220,
          fixed: 'right'
        }
      ],

      meansSelectVaule: 1,
      means: [
        {
          value: 1,
          label: '按月收取'
        },
        {
          value: 2,
          label: '按年收取-折算'
        },
        {
          value: 3,
          label: '按年收取-取整'
        }
      ],
      // 增员生效时间值
      addEffectiveValue: '',
      // 减员生效时间值
      reduceEffectiveValue: '',
      // 截止时间
      endTime: [{ value: 1, label: '1号' }, { value: 2, label: '2号' }, { value: 3, label: '3号' }, { value: 4, label: '4号' }, { value: 5, label: '5号' }, { value: 6, label: '6号' }, { value: 7, label: '7号' }, { value: 8, label: '8号' }, { value: 9, label: '9号' }, { value: 10, label: '10号' }, { value: 11, label: '11号' }, { value: 12, label: '12号' }, { value: 13, label: '13号' }, { value: 14, label: '14号' }, { value: 15, label: '15号' }, { value: 16, label: '16号' }, { value: 17, label: '17号' }, { value: 18, label: '18号' }, { value: 19, label: '19号' }, { value: 20, label: '20号' }, { value: 21, label: '21号' }, { value: 22, label: '22号' }, { value: 23, label: '23号' }, { value: 24, label: '24号' }, { value: 25, label: '25号' }, { value: 26, label: '26号' }, { value: 27, label: '27号' }, { value: 28, label: '28号' }, { value: 29, label: '29号' }, { value: 30, label: '30号' }, { value: 31, label: '31号' }],
      monthShow: false,
      month: [{ value: 1, label: '1月' }, { value: 2, label: '2月' }, { value: 3, label: '3月' }, { value: 4, label: '4月' }, { value: 5, label: '5月' }, { value: 6, label: '6月' }, { value: 7, label: '7月' }, { value: 8, label: '8月' }, { value: 9, label: '9月' }, { value: 10, label: '10月' }, { value: 11, label: '11月' }, { value: 12, label: '12月' }]
    }
  },
  computed: {
    actionArr () {
      let arr = this.$store.state.user.actionAccess.map(item => {
        return item.code
      })
      return arr
    },
    // 新增
    hasCreate () {
      return this.actionArr.indexOf('Create') > -1
    },
    // 查看
    hasView () {
      return this.actionArr.indexOf('View') > -1
    },
    // 编辑
    hasEdit () {
      return this.actionArr.indexOf('Edit') > -1
    },
    // 查询
    hasFind () {
      return this.actionArr.indexOf('Find') > -1
    },
    // 批量导入
    hasImport () {
      return this.actionArr.indexOf('Import') > -1
    },
    // 导出
    hasExport () {
      return this.actionArr.indexOf('Export') > -1
    },
    // 启用
    hasEnabled () {
      return this.actionArr.indexOf('Enabled') > -1
    },
    // 禁用
    hasDisEnabled () {
      return this.actionArr.indexOf('DisEnabled') > -1
    }
  },
  mounted () {
    this.getCodeList()
    this.getProvince()
    this.getEnum()
    this.getSelectIdList()
  },
  methods: {
    // 获取服务形式下拉
    getSelectIdList () {
      codeManageApi.GetSelectIdList().then(res => {
        console.log(res)
        if (res.data.success) {
          this.serviceFormArr = res.data.data
        }
      })
    },
    handleMaxSizeTen () {
      this.$Message.error({
        content: '您上传的文件太大，上传文件大小不能超过10M',
        duration: 10,
        closable: true
      })
    },
    importBtn () {
      this.$refs.BatchImportModal.openModal()
    },

    getEnabled(id,status){
      codeManageApi.Enabled({
        Ids:id,
        Type: this.securityType,
        Enabled:status,
      }).then(res => {
        if (res.data.success) {
          this.getCodeList()
        } else {
          this.$Message.error({
            content: res.data.message,
            duration: 10,
            closable: true
          })
        }
      })
    },
    // 导出
    exportBtn () {
      // if (this.selectedId) {
      codeManageApi.exportCode({
        IdList: this.selectedId,
        areaGUID: this.areaName[this.areaName.length - 1],
        SecurityNO: this.securityNO,
        CompanyName: this.companyName,
        SecurityType: this.securityType,
        IsReceivables: this.isReceivables,
        IsInvoice: this.isInvoice,
        ServiceForm: this.serviceForm,
        CommissionerUserId: this.commissionerUserId
      }).then(res => {
        if (res.data.success) {
          let objectUrl = '/' + res.data.data.replace(/\\/g, '\/')
          console.log(objectUrl)
          const link = document.createElement('a')
          link.download = ''
          link.href = objectUrl
          link.click()
        } else {
          this.$Message.error({
            content: res.data.message,
            duration: 10,
            closable: true
          })
        }
      })
    },
    /**
     * 分页页码变动
     */
    onpageSizeChange (val) {
      this.PageIndex = 1
      this.PageSize = val
      this.getCodeList()
    },
    // 获取全部省份
    getProvince () {
      dataApi.getProvince().then(res => {
        this.ProvinceArr = res.data.data.map(item => {
          return {
            ...item,
            label: item.name,
            value: item.id,
            children: [],
            loading: false
          }
        })
      })
    },
    /**
     * 分级查询地区
     */
    loadDataCity (val, callback) {
      val.loading = true
      if (val.levelID === 2) {
        dataApi.getCity({ parentId: val.value }).then(res => {
          val.children = res.data.data.map(item => {
            return {
              ...item,
              label: item.name,
              value: item.id,
              children: [],
              loading: false
            }
          })
          val.loading = false
          callback()
        })
      } else {
        dataApi.getArea({ parentId: val.value }).then(res => {
          val.children = res.data.data.map(item => {
            return { ...item, label: item.name, value: item.id }
          })
          val.loading = false
          callback()
        })
      }
    },
    // 计算个人缴纳金额
    async totalMoneyEmployee (data) {
      let res = await systemApi.getTotalAmount({
        Money: data.employee.baseAmount,
        Precision: data.precision,
        Percent: data.employee.percent
      })
      data.employee.totalAmount = res.data.data
    },
    // 计算单位缴纳金额
    async totalMoneyCompany (data) {
      let res = await systemApi.getTotalAmount({
        Money: data.company.baseAmount,
        Precision: data.precision,
        Percent: data.company.percent
      })
      data.company.totalAmount = res.data.data
    },
    // 计算
    totalMoney (data) {
      this.totalMoneyEmployee(data)
      this.totalMoneyCompany(data)
    },
    // 获取列表
    async getCodeList () {
      this.loading = true
      let res = await codeManageApi.getCodeList({
        areaGUID: this.areaName[this.areaName.length - 1],
        SecurityNO: this.securityNO,
        CompanyName: this.companyName,
        SecurityType: this.securityType,
        IsReceivables: this.isReceivables,
        IsInvoice: this.isInvoice,
        ServiceForm: this.serviceForm,
        CommissionerUserId: this.commissionerUserId,
        Enabled: this.enabled,
        PageIndex: this.PageIndex,
        PageSize: this.PageSize
      })
      this.selectedId = ''
      this.codeListData = res.data.data
      this.codeTotal = res.data.totalRows
      this.areaCount = res.data.areaCount
      this.securityNoCount = res.data.securityNoCount
      this.loading = false
    },
    // 删除编号
    async deleteCode () {
      let res = await codeManageApi.deleteCode({
        id: this.selectedId
      })
      if (res.data.success) {
        this.$Message.success('删除成功！！')
        this.selectedId = ''
        this.getCodeList()
      } else {
        this.$Message.error({
          content: res.data.message,
          duration: 10,
          closable: true
        })
      }
    },
    // 获取下拉
    async getEnum () {
      let groupNames = 'common.precision,common.securitypaymenttype,common.reduceeffecttype,common.totaltype,common.changeoperateduration,user.supplierlist'
      let res = await dataApi.getEnum({
        groupName: groupNames
      })
      this.precisionSelect = this.getItems(res.data, 'common.precision')
      this.securityPaymentType = this.getItems(res.data, 'common.securitypaymenttype')
      this.countType = this.getItems(res.data, 'common.totaltype')
      this.effectiveTime = this.getItems(res.data, 'common.reduceeffecttype')
      this.commissionerUserIdArr = this.getItems(res.data, 'user.supplierlist')
    },
    getItems (arr, key) {
      let object = arr.find((item) => {
        return item.group === key
      })
      return object.items
    },
    // 获取查看时的详情信息
    getCodeDetail () {
      this.spinShow = true
      codeManageApi.getCodeDetail({
        id: this.detail_id
      }).then((res) => {
        this.codeDetailInfo = res.data.data
        this.spinShow = false
        this.dt_area_name = this.codeDetailInfo.areaName
        this.dt_area_name_id = this.codeDetailInfo.areaGUID
        this.dt_planName = this.codeDetailInfo.planName
        if (this.codeDetailInfo.seriousIllnessPayment && this.codeDetailInfo.seriousIllnessPayment.paymentType != 'Month') {
          this.monthShow = true
        } else {
          this.monthShow = false
        }
      })
    },
    // 获取新增时的信息
    async getAddModalInfo () {
      let res = await codeManageApi.addModalInfo({
        type: this.securityType

      })
      this.addDetailInfo = res.data.data
      if (this.addDetailInfo.seriousIllnessPayment.paymentType != 'Month') {
        this.monthShow = true
      } else {
        this.monthShow = false
      }
    },
    detailServiceFormChange (val) {
      console.log(val)
      if (val) {
        this.codeDetailInfo.serviceFormName = val.label
      } else {
        this.codeDetailInfo.serviceFormName = ''
      }
    },
    detailCommissionerUserIdChange (val) {
      if (val) {
        this.codeDetailInfo.commissionerUserName = val.label
      } else {
        this.codeDetailInfo.commissionerUserName = ''
      }
    },
    // 滞纳金更改
    add_lateFeesCanCollectChnage (val) {
      if (val){

      } else {
        this.add_lateFeesPercent = 0
        this.add_lateFeesStartMonth = 0
      }
    },
    detailLateFeesCanCollectChnage(val) {
      if (val){

      } else {
        this.codeDetailInfo.lateFeesPercent = 0
        this.codeDetailInfo.lateFeesStartMonth = 0
      }
    },

    // 保存修改
    async saveRevise () {
      this.isCheckModel = true
      let res = await codeManageApi.saveReviseCode({
        SecurityNO: this.codeDetailInfo.securityNO,
        CompanyName: this.codeDetailInfo.companyName,
        PlanGUID: this.codeDetailInfo.planGUID,
        Id: this.codeDetailInfo.id,
        AreaGUID: this.dt_area_name_id,
        IsReceivables: this.codeDetailInfo.isReceivables,
        IsInvoice: this.codeDetailInfo.isInvoice,
        ServiceForm: this.codeDetailInfo.serviceForm,
        ServiceFormName: this.codeDetailInfo.serviceFormName,
        CommissionerUserId: this.codeDetailInfo.commissionerUserId,
        CommissionerUserName: this.codeDetailInfo.commissionerUserName,
        Enabled: this.codeDetailInfo.enabled,
        // LateFeesCanCollect: this.codeDetailInfo.lateFeesCanCollect,
        // LateFeesStartMonth: this.codeDetailInfo.lateFeesStartMonth,
        // LateFeesPercent: this.codeDetailInfo.lateFeesPercent,
        PlanName: this.codeDetailInfo.planName,
        SecurityType: this.securityType,
        PayBackMaxMonth: this.codeDetailInfo.payBackMaxMonth,
        ReduceEffectType: this.codeDetailInfo.reduceEffectType,
        IncreasDay: this.codeDetailInfo.increasDay,
        ReduceDay: this.codeDetailInfo.reduceDay,
        TotalType: this.codeDetailInfo.totalType,
        ChangeOperateDuration: this.codeDetailInfo.changeOperateDuration,
        SeriousIllnessPayment: this.codeDetailInfo.seriousIllnessPayment,
        Details: this.codeDetailInfo.details
      })
      if (res.data.success) {
        this.$Message.success('修改成功！')
        this.checkModalTitle = '社保编号查看'
        this.getCodeList()
      } else {
        this.$Message.error({
          content: res.data.message,
          duration: 10,
          closable: true
        })
      }
    },
    addServiceFormChange (val) {
      if (val) {
        this.add_serviceFormName = val.label
      } else {
        this.add_serviceFormName = ''
      }
    },
    addCommissionerUserIdChange (val) {
      if (val) {
        this.add_commissionerUserName = val.label
      } else {
        this.add_commissionerUserName = ''
      }
    },
    // 确定新增
    async addSave () {
      let res = await codeManageApi.saveReviseCode({
        SecurityNO: this.add_securityNO,
        CompanyName: this.add_companyName,
        PlanGUID: this.add_planGUID,
        AreaGUID: this.add_area_name[this.add_area_name.length - 1],
        IsReceivables: this.add_isReceivables,
        IsInvoice: this.add_isInvoice,
        ServiceForm: this.add_serviceForm,
        ServiceFormName: this.add_serviceFormName,
        CommissionerUserId: this.add_commissionerUserId,
        CommissionerUserName: this.add_commissionerUserName,
        Enable: this.add_enabled,
        // LateFeesCanCollect: this.add_lateFeesCanCollect,
        // LateFeesStartMonth: this.add_lateFeesStartMonth,
        // LateFeesPercent: this.add_lateFeesPercent,
        SecurityType: this.securityType,
        PayBackMaxMonth: this.addDetailInfo.payBackMaxMonth,
        ReduceEffectType: this.addDetailInfo.reduceEffectType,
        IncreasDay: this.addDetailInfo.increasDay,
        ReduceDay: this.addDetailInfo.reduceDay,
        TotalType: this.addDetailInfo.totalType,
        ChangeOperateDuration: this.addDetailInfo.changeOperateDuration,
        SeriousIllnessPayment: this.addDetailInfo.seriousIllnessPayment,
        Details: this.addDetailInfo.details
      })
      if (res.data.success) {
        this.$Message.success('保存成功！')
        this.addModalShow = false
        this.getCodeList()
      } else {
        this.$Message.error({
          content: res.data.message,
          duration: 10,
          closable: true
        })
        this.addModalShow = true
      }
    },
    // 查询
    searchBtn () {
      this.PageIndex = 1
      this.getCodeList()
    },
    // table选择
    tableSelectChange (value) {
      // console.log(value)
      let arr = value.map((item) => {
        return item.id
      })
      this.selectedId = arr.join(',')
      console.log(this.selectedId)
    },
    // 删除按钮
    cancelFn () {
      if (this.selectedId) {
        this.$Modal.confirm({
          title: '确定删除？',
          content: '<p>确认后选择的社保编号将被删除！</p>',
          onOk: () => {
            this.deleteCode()
          },
          onCancel: () => {

          }
        })
      } else {
        this.$Message.warning('您还未选择任何编号！')
      }
    },
    // 分页
    pageChangeFn (index) {
      this.PageIndex = index
      this.getCodeList()
    },
    meansSelectFn (value) {
      this.meansSelectVaule = value
      if (this.meansSelectVaule != 1) {
        this.monthShow = true
      } else {
        this.monthShow = false
      }
    },
    monthSelectFn (e) {
      console.log(e)
    },
    // 全部补缴
    bjAllFn (data) {
      data.forEach((item) => {
        if (['Pension', 'MedicalCare', 'Unemployment', 'InjuryOnTheJob', 'Birth'].indexOf(item.securityTypeCode) > -1) {
          item.isPayBack = this.allIsPayBack
        }
      })
    },
    // 全部默认基数设置
    baseAmountSet (data) {
      data.forEach((item) => {
        if (item.securityTypeCode === 'InjuryOnTheJob' || item.securityTypeCode === 'Birth') {
          if (item.company) {
            item.company.baseAmount = this.baseAmountValue
            this.totalMoneyCompany(item)
          }
        } else if (item.securityTypeCode === 'Pension' || item.securityTypeCode === 'MedicalCare' || item.securityTypeCode === 'Unemployment') {
          if (item.company) {
            item.company.baseAmount = this.baseAmountValue
            this.totalMoneyCompany(item)
          }
          if (item.employee) {
            item.employee.baseAmount = this.baseAmountValue
            this.totalMoneyEmployee(item)
          }
        }
      })
    },
    // 全部最低基数设置
    minAmountSet (data) {
      data.forEach((item) => {
        if (item.securityTypeCode === 'InjuryOnTheJob' || item.securityTypeCode === 'Birth') {
          if (item.company) {
            item.company.minAmount = this.minAmountValue
          }
        } else if (item.securityTypeCode === 'Pension' || item.securityTypeCode === 'MedicalCare' || item.securityTypeCode === 'Unemployment') {
          if (item.company) {
            item.company.minAmount = this.minAmountValue
          }
          if (item.employee) {
            item.employee.minAmount = this.minAmountValue
          }
        }
      })
    },
    // 全部最高基数设置
    maxAmountSet (data) {
      data.forEach((item) => {
        if (item.securityTypeCode === 'InjuryOnTheJob' || item.securityTypeCode === 'Birth') {
          if (item.company) {
            item.company.maxAmount = this.maxAmountValue
          }
        } else if (item.securityTypeCode === 'Pension' || item.securityTypeCode === 'MedicalCare' || item.securityTypeCode === 'Unemployment') {
          if (item.company) {
            item.company.maxAmount = this.maxAmountValue
          }
          if (item.employee) {
            item.employee.maxAmount = this.maxAmountValue
          }
        }
      })
    },
    // 修改-全部精度设置
    precisionSet (val) {
      console.log(val)
      this.codeDetailInfo.details.forEach((item) => {
        if (['Pension', 'MedicalCare', 'Unemployment', 'InjuryOnTheJob', 'Birth'].indexOf(item.securityTypeCode) > -1) {
          item.employee.precision = val
          item.company.precision = val
          this.totalMoneyEmployee(item)
          this.totalMoneyCompany(item)
        }
      })
    },
    // 新增-全部精度设置
    add_precisionSet (val) {
      // console.log(val)
      // console.log('************')
      this.addDetailInfo.details.forEach((item) => {
        if (['Pension', 'MedicalCare', 'Unemployment', 'InjuryOnTheJob', 'Birth'].indexOf(item.securityTypeCode) > -1) {
          item.employee.precision = val
          item.company.precision = val
          this.totalMoneyEmployee(item)
          this.totalMoneyCompany(item)
        }
      })
    },

    // 增员起止时间校验
    increasDayVerification (data) {
      if (data.increasDay.end < data.increasDay.begin) {
        this.$Message.warning('截止时间不能早于开始时间！！')
        data.increasDay.end = data.increasDay.begin
      }
    },
    // 减员起止时间校验
    reduceDayVerification (data) {
      if (data.reduceDay.end < data.reduceDay.begin) {
        this.$Message.warning('截止时间不能早于开始时间！！')
        data.reduceDay.end = data.reduceDay.begin
      }
    },
    // 新增按钮
    addFn () {
      this.addModalShow = true
      this.add_serviceForm = ''
      this.add_serviceFormName = ''
      this.add_commissionerUserId = ''
      this.add_commissionerUserName = ''
      this.add_securityNO = ''
      this.add_companyName = ''
      this.add_area_name = []
      this.add_planGUID = ''
      this.baseAmountValue = ''
      this.add_dis = true
      this.add_enabled = true
      // 全部--最低基数
      this.minAmountValue = ''
      // 全部--最高基数
      this.maxAmountValue = ''
      // 全部补缴
      this.allIsPayBack = false
      // this.allPrecision = ''
    },
    // 查看
    checkInfoFn (id) {
      this.detail_id = id
      this.checkModalTitle = '社保编号查看'
      this.isCheckModel = true
      this.checkModalShow = true
      // 全部--默认基数
      this.baseAmountValue = ''
      // 全部--最低基数
      this.minAmountValue = ''
      // 全部--最高基数
      this.maxAmountValue = ''
      // 全部补缴
      this.allIsPayBack = false
      // this.allPrecision = ''
      this.getCodeDetail()
    },
    // 修改按钮
    getReviseAfInfo (id) {
      this.detail_id = id
      this.isCheckModel = false
      this.checkModalTitle = '社保编号修改'
      this.checkModalShow = true
      // 全部--默认基数
      this.baseAmountValue = ''
      // 全部--最低基数
      this.minAmountValue = ''
      // 全部--最高基数
      this.maxAmountValue = ''
      // 全部补缴
      this.allIsPayBack = false
      // this.allPrecision = ''
      this.getCodeDetail()
    },
    // 查看弹窗中的关闭
    closeCheckModal () {
      this.checkModalShow = false
    },
    // 查看弹窗中的修改按钮
    reviseFromModal () {
      this.checkModalTitle = '编号修改'
      this.isCheckModel = false
    },
    // 查看修改弹窗中的确认修改按钮
    confirmRevise () {
      this.saveRevise()
    },
    // 新增弹窗中的确定
    confirmFn () {
      this.addSave()
      this.monthShow = false
    },
    // 新增地区选择时执行该方法
    cascaderVisibleChange (val) {
      console.log(val)
      if (val.length > 0) {
        this.get_add_planOptions(val)
      } else {
        this.add_dis = true
      }
    },
    // 根据区域获取参保方案列表
    async get_add_planOptions (val) {
      let optionData = await codeManageApi.getPlanOptions({
        AreaGUID: val[val.length - 1],
        SecurityType: this.securityType
      })
      if (optionData.data.success) {
        this.add_planOptions = optionData.data.data
        this.add_dis = false
      }
    },
    // 参保方案改变
    add_planGUIDChange (val) {
      console.log(val)
      if (val) {
        this.getPlanDetail(val)
      } else {
        return false
      }
    },
    // 获取参保方案的明细
    async getPlanDetail (val) {
      this.spinShow = true
      let res = await systemApi.getPlanDetail({
        id: val
      })
      this.addDetailInfo = res.data.data
      this.spinShow = false
      if (this.addDetailInfo.seriousIllnessPayment.paymentType != 'Month') {
        this.monthShow = true
      } else {
        this.monthShow = false
      }
    }
  }
}
</script>
<style lang="less">
  .ss-add-modal-lzw{
    .ivu-modal-wrap{
      top:5%;
      bottom: 5%;
      left: 5%;
      right: 5%;
    }
    .ivu-input[disabled], fieldset[disabled] .ivu-input{
      color: #333;
    }
    .ivu-checkbox-disabled.ivu-checkbox-checked .ivu-checkbox-inner:after{
      border-color: #333;
    }
    .ivu-select-disabled .ivu-select-selection{
      color: #333;
    }
    .ivu-select-input[disabled]{
      color: #333;
      -webkit-text-fill-color: #333;
    }
  }
</style>

<style lang="less" scoped>
  // .d-flex{
  //   display: flex;
  //   align-items: center;
  // }
  span.red{
    color: #ed4014;
  }
  .search-form-lzw{
    .ivu-col{
      display: flex;
      align-items: center;
      span.label-txt{
        vertical-align: middle;
        float: left;
        min-width: 80px;
        font-size: 12px;
        color: #515a6e;
        line-height: 1;
        padding: 10px 12px 10px 0;
        box-sizing: border-box;
      }
      .ivu-select{
        flex: 1;
      }
      .ivu-input-wrapper{
        flex: 1;
      }
    }
  }
  .lzw-style-modal{
    .ivu-divider-horizontal{
      margin: 10px 0;
    }
  }
  .modal-top{
    background-color: #fff;
    height: 200px;
  }
  .add-modal{
    position: absolute;
    top: 220px;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 10px;
  }
</style>
